package o;

import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.FrameLayout;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetBehavior.c;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.aqu.d;
import o.aqu.f;
import o.aqu.i;
import o.aqu.j;

public class arj extends ag {
    private c ˊ = new c(this) {
        final /* synthetic */ arj ˏ;

        {
            this.ˏ = r1;
        }

        public void ˋ(@NonNull View view, int i) {
            if (i == 5) {
                this.ˏ.cancel();
            }
        }

        public void ॱ(@NonNull View view, float f) {
        }
    };
    boolean ˋ = true;
    private boolean ˎ;
    private BottomSheetBehavior<FrameLayout> ˏ;
    private boolean ॱ = true;

    public arj(@NonNull Context context, @StyleRes int i) {
        super(context, ˏ(context, i));
        ˎ(1);
    }

    public void setContentView(@LayoutRes int i) {
        super.setContentView(ˎ(i, null, null));
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Window window = getWindow();
        if (window != null) {
            if (VERSION.SDK_INT >= 21) {
                window.clearFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
                window.addFlags(Integer.MIN_VALUE);
            }
            window.setLayout(-1, -1);
        }
    }

    public void setContentView(View view) {
        super.setContentView(ˎ(0, view, null));
    }

    public void setContentView(View view, LayoutParams layoutParams) {
        super.setContentView(ˎ(0, view, layoutParams));
    }

    public void setCancelable(boolean z) {
        super.setCancelable(z);
        if (this.ˋ != z) {
            this.ˋ = z;
            if (this.ˏ != null) {
                this.ˏ.ˊ(z);
            }
        }
    }

    protected void onStart() {
        super.onStart();
        if (this.ˏ != null && this.ˏ.ˏ() == 5) {
            this.ˏ.ˊ(4);
        }
    }

    public void setCanceledOnTouchOutside(boolean z) {
        super.setCanceledOnTouchOutside(z);
        if (z && !this.ˋ) {
            this.ˋ = true;
        }
        this.ॱ = z;
        this.ˎ = true;
    }

    private View ˎ(int i, View view, LayoutParams layoutParams) {
        FrameLayout frameLayout = (FrameLayout) View.inflate(getContext(), i.ˋ, null);
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) frameLayout.findViewById(j.ˏ);
        if (i != 0 && view == null) {
            view = getLayoutInflater().inflate(i, coordinatorLayout, false);
        }
        View view2 = (FrameLayout) coordinatorLayout.findViewById(j.ˋ);
        this.ˏ = BottomSheetBehavior.ॱ(view2);
        this.ˏ.ॱ(this.ˊ);
        this.ˏ.ˊ(this.ˋ);
        if (layoutParams == null) {
            view2.addView(view);
        } else {
            view2.addView(view, layoutParams);
        }
        coordinatorLayout.findViewById(j.ͺ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ arj ॱ;

            {
                this.ॱ = r1;
            }

            public void onClick(View view) {
                if (this.ॱ.ˋ && this.ॱ.isShowing() && this.ॱ.ॱ()) {
                    this.ॱ.cancel();
                }
            }
        });
        ViewCompat.ˏ(view2, new hc(this) {
            final /* synthetic */ arj ˏ;

            {
                this.ˏ = r1;
            }

            public void ˋ(View view, in inVar) {
                super.ˋ(view, inVar);
                if (this.ˏ.ˋ) {
                    inVar.ˊ(1048576);
                    inVar.ˋॱ(true);
                    return;
                }
                inVar.ˋॱ(false);
            }

            public boolean ˊ(View view, int i, Bundle bundle) {
                if (i != 1048576 || !this.ˏ.ˋ) {
                    return super.ˊ(view, i, bundle);
                }
                this.ˏ.cancel();
                return true;
            }
        });
        view2.setOnTouchListener(new OnTouchListener(this) {
            final /* synthetic */ arj ˏ;

            {
                this.ˏ = r1;
            }

            public boolean onTouch(View view, MotionEvent motionEvent) {
                return true;
            }
        });
        return frameLayout;
    }

    boolean ॱ() {
        if (!this.ˎ) {
            TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(new int[]{16843611});
            this.ॱ = obtainStyledAttributes.getBoolean(0, true);
            obtainStyledAttributes.recycle();
            this.ˎ = true;
        }
        return this.ॱ;
    }

    private static int ˏ(Context context, int i) {
        if (i != 0) {
            return i;
        }
        TypedValue typedValue = new TypedValue();
        if (context.getTheme().resolveAttribute(d.ˏ, typedValue, true)) {
            return typedValue.resourceId;
        }
        return f.ॱ;
    }
}
